-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update to use Polymer's properties-mixin #2
Conversation
* _indvalidateProperties always triggers render. * remove bespoke `html`
src/@polymer/polymer-lit-element.ts
Outdated
export class PolymerLitElement extends PropertiesMixin(HTMLElement) { | ||
|
||
ready() { | ||
this.attachShadow({mode: 'open'}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given this line, I think we can add a shadowRoot: ShadowRoot
as property on this class. This should remove the need for (el.shadowRoot as ShadowRoot)
in every usage of this field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HTMLElement
already has a shadowRoot
property. It's just possibly undefined, so it needs a trailing !
modifier.
src/@polymer/polymer-lit-element.ts
Outdated
export class PolymerLitElement extends PropertiesMixin(HTMLElement) { | ||
|
||
ready() { | ||
this.attachShadow({mode: 'open'}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HTMLElement
already has a shadowRoot
property. It's just possibly undefined, so it needs a trailing !
modifier.
src/@polymer/polymer-lit-element.ts
Outdated
// TODO(sorvell): propertiesChanged should have `_getData` | ||
const result = this.render(this.__data); | ||
if (result) { | ||
render(result, this.shadowRoot as DocumentFragment); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
render(result, this.shadowRoot!)
README.md
Outdated
} | ||
|
||
// Render method should return a `TemplateResult` using the provided lit-html `html` tag function | ||
render(props, html) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove html
README.md
Outdated
} | ||
|
||
// Render method should return a `TemplateResult` using the provided lit-html `html` tag function | ||
render(props, html) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than props
as an argument, I'd use destructuring:
render({foo}) {
return html`... ${foo}`;
}
demo/polymer-lit-element.html
Outdated
super.ready(); | ||
} | ||
|
||
render(props) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use destructuring
src/@polymer/polymer-lit-element.ts
Outdated
|
||
get nextRendered() { | ||
if (!this._nextRendered) { | ||
this._nextRendered = new Promise((resolve) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Later I think it'll be good to reject in case there's an exception during rendering. ie:
_flushProperties() {
super._flushProperties();
try {
const result = this.render(this.__data);
if (result) {
render(result, this.shadowRoot!);
}
} catch (e) {
if (this._nextRenderedReject) {
this._nextRenderedReject(e);
}
}
* destructuring in render calls * avoid returning `nextRendered` in `invalidate` for now.
"Made to share" and "Interoperable" seemed redundant. Fast/light is most valuable to users. Standards seems like lit#2.
"Made to share" and "Interoperable" seemed redundant. Fast/light is most valuable to users. Standards seems like #2.
Add js-framework-benchmarks for lit-html
NOTE, do not merge yet. Depends on Polymer 3.x being released on npm.